<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <input type="text" id="inp1" /> <br />
      你说啥: <span id="inp2"></span>
    </div>

    <script src="./vue.js"></script>
    <script>
      var inp1 = document.getElementById('inp1')
      var inp2 = document.getElementById('inp2')
      var obj = {}
      Object.defineProperty(obj, 'val', {
        // 拦截obj 对象的val的值 赋值给输入框1 的值 和显示给 input2的dom元素
        set: function(newval) {
          inp1.value = newval
          inp2.innerHTML = newval
        }
      })
      // 输入改变obj对象的val值
      inp1.addEventListener('keydown', function(e) {
        obj.val = e.target.value
      })
    </script>
  </body>
</html>
